<!--
    JBoss, Home of Professional Open Source
    Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
    contributors by the @authors tag. See the copyright.txt in the
    distribution for a full listing of individual contributors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>temperature-converter</title>
</head>

<body>

    <h1>JBoss EAP Temperature Converter Service</h1>
    <p>Enter the temperature you wish to convert. 
    Then click <b>C</b> for Celsius or <b>F</b> for Fahrenheit to choose the temperature scale.
    </p>
    <div id="container">
        <h:form id="convertForm">
            <h:panelGrid columns="2">
                <h:outputLabel for="radio">Scale (default):</h:outputLabel>
                <h:selectOneRadio value="#{temperatureConverter.defaultScale}" id="radio" converter="#{scaleConverter}">
                    <f:selectItems value="#{scaleConverter.scales}" var="scale" itemLabel="#{scale.symbol}" itemValue="#{scale}" />
                </h:selectOneRadio>
                <h:outputLabel for="sourceTemperature">Temperature:</h:outputLabel>
                <h:inputText id="sourceTemperature" value="#{temperatureConverter.sourceTemperature}" />
                <h:commandButton id="convert" value="Convert" action="#{temperatureConverter.convert}" />
                <h:messages />
            </h:panelGrid>
        </h:form>
        <h:form id="response">
            <h:panelGrid columns="2">
                <h:outputLabel for="temperature">Converts to:</h:outputLabel>
                <h:outputLabel id="temperature" value="#{temperatureConverter.temperature}" />
            </h:panelGrid>
        </h:form>
        <hr />
        <p>How the temperature conversion works:</p>
        <ul>
            <li>The input temperature string is parsed using a regular expression that expects a floating point number.
        The parsed temperature value is combined with the selected or default temperature scale to convert the temperature to 
        the new scale.</li>
            <li>If the input temperature is null or can not be converted, an error message is displayed and 'Invalid temperature' is 
        returned for the result.</li>
            <li>Both the parsed input temperature and the resulting converted temperature are truncated to 3 decimal places.</li>
        </ul>

    </div>

</body>
</html>
